Skip to content

Conversation

@kikairoya
Copy link
Contributor

@kikairoya kikairoya commented Sep 2, 2025

Fixes #152328

For exporting:
Since the declaration/definition of getPollyPluginInfo is embedded into the LLVM DLL using add_llvm_pass_plugin, which defines LLVM_BUILD_STATIC by the effect of DISABLE_LLVM_LINK_LLVM_DYLIB, it must be declared with LLVM_ALWAYS_EXPORT.
Just a LLVM_ABI is required after #158023 gets merged.

For importing:
The annotation LLVM_ABI is required in the body of the macro HANDLE_EXTENTION, which generates the declaration of getPollyPluginInfo from the CMake-generated file "llvm/Support/Extension.def".

@kikairoya
Copy link
Contributor Author

cc: @andrurogerz

@github-actions
Copy link

github-actions bot commented Sep 2, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. flang:driver flang Flang issues not falling into any other category LTO Link time optimization (regular/full LTO or ThinLTO) labels Sep 7, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 7, 2025

@llvm/pr-subscribers-lto

@llvm/pr-subscribers-clang

Author: Tomohiro Kashiwada (kikairoya)

Changes

Fixes #152328

For exporting:
Since the declaration/definition of getPollyPluginInfo is embedded into the LLVM DLL using add_llvm_pass_plugin, which defines LLVM_BUILD_STATIC by the effect of DISABLE_LLVM_LINK_LLVM_DYLIB, it must be declared with LLVM_ALWAYS_EXPORT.

For importing:
The annotation LLVM_ABI is required in the body of the macro HANDLE_EXTENTION, which generates the declaration of getPollyPluginInfo from the CMake-generated file "llvm/Support/Extension.def".


Full diff: https://github.com/llvm/llvm-project/pull/156440.diff

8 Files Affected:

  • (modified) clang/lib/CodeGen/BackendUtil.cpp (+1-1)
  • (modified) flang/lib/Frontend/FrontendActions.cpp (+1-1)
  • (modified) llvm/docs/WritingAnLLVMNewPMPass.rst (+2-2)
  • (modified) llvm/lib/Extensions/Extensions.cpp (+1-1)
  • (modified) llvm/lib/LTO/LTOBackend.cpp (+1-1)
  • (modified) llvm/tools/bugpoint/bugpoint.cpp (+1-1)
  • (modified) llvm/tools/opt/NewPMDriver.cpp (+1-1)
  • (modified) polly/include/polly/RegisterPasses.h (+3-1)
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 3f095c03397fd..2e6f9e90f2db6 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -94,7 +94,7 @@ using namespace clang;
 using namespace llvm;
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 namespace llvm {
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 3bef6b1c31825..e61dee5e26636 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -87,7 +87,7 @@ constexpr llvm::StringLiteral timingIdBackend =
 
 // Declare plugin extension function declarations.
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 /// Save the given \c mlirModule to a temporary .mlir file, in a location
diff --git a/llvm/docs/WritingAnLLVMNewPMPass.rst b/llvm/docs/WritingAnLLVMNewPMPass.rst
index ea30d637347f1..5e41a939081a3 100644
--- a/llvm/docs/WritingAnLLVMNewPMPass.rst
+++ b/llvm/docs/WritingAnLLVMNewPMPass.rst
@@ -254,7 +254,7 @@ See the definition of ``add_llvm_pass_plugin`` for more CMake details.
 The pass must provide at least one of two entry points for the new pass manager,
 one for static registration and one for dynamically loaded plugins:
 
-- ``llvm::PassPluginLibraryInfo get##Name##PluginInfo();``
+- ``LLVM_ABI llvm::PassPluginLibraryInfo get##Name##PluginInfo();``
 - ``extern "C" ::llvm::PassPluginLibraryInfo llvmGetPassPluginInfo() LLVM_ATTRIBUTE_WEAK;``
 
 Pass plugins are compiled and linked dynamically by default. Setting
@@ -268,7 +268,7 @@ To make ``PassBuilder`` aware of statically linked pass plugins:
 .. code-block:: c++
 
     // Declare plugin extension function declarations.
-    #define HANDLE_EXTENSION(Ext) llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+    #define HANDLE_EXTENSION(Ext) LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
     #include "llvm/Support/Extension.def"
 
     ...
diff --git a/llvm/lib/Extensions/Extensions.cpp b/llvm/lib/Extensions/Extensions.cpp
index 0d25cbda38e00..67b1fa087e0c1 100644
--- a/llvm/lib/Extensions/Extensions.cpp
+++ b/llvm/lib/Extensions/Extensions.cpp
@@ -1,6 +1,6 @@
 #include "llvm/Passes/PassPlugin.h"
 #define HANDLE_EXTENSION(Ext)                                                  \
-		llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index ce42fc526beac..37ff7a4968e41 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -178,7 +178,7 @@ Error Config::addSaveTemps(std::string OutputFileName, bool UseInputModulePath,
 }
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 #undef HANDLE_EXTENSION
 
diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp
index 87581e80a2496..741374bfaf162 100644
--- a/llvm/tools/bugpoint/bugpoint.cpp
+++ b/llvm/tools/bugpoint/bugpoint.cpp
@@ -93,7 +93,7 @@ class AddToDriver : public legacy::FunctionPassManager {
 }
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 int main(int argc, char **argv) {
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index b9b8929a0f703..81909ea94f227 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -344,7 +344,7 @@ static void registerEPCallbacks(PassBuilder &PB) {
 }
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 #undef HANDLE_EXTENSION
 
diff --git a/polly/include/polly/RegisterPasses.h b/polly/include/polly/RegisterPasses.h
index 3a81e1ba7487d..3c358c8d77d4c 100644
--- a/polly/include/polly/RegisterPasses.h
+++ b/polly/include/polly/RegisterPasses.h
@@ -13,6 +13,8 @@
 #ifndef POLLY_REGISTER_PASSES_H
 #define POLLY_REGISTER_PASSES_H
 
+#include "llvm/Support/Compiler.h"
+
 namespace llvm {
 class PassRegistry;
 class PassBuilder;
@@ -27,6 +29,6 @@ void initializePollyPasses(llvm::PassRegistry &Registry);
 void registerPollyPasses(llvm::PassBuilder &PB);
 } // namespace polly
 
-llvm::PassPluginLibraryInfo getPollyPluginInfo();
+LLVM_ALWAYS_EXPORT llvm::PassPluginLibraryInfo getPollyPluginInfo();
 
 #endif

@llvmbot
Copy link
Member

llvmbot commented Sep 7, 2025

@llvm/pr-subscribers-flang-driver

Author: Tomohiro Kashiwada (kikairoya)

Changes

Fixes #152328

For exporting:
Since the declaration/definition of getPollyPluginInfo is embedded into the LLVM DLL using add_llvm_pass_plugin, which defines LLVM_BUILD_STATIC by the effect of DISABLE_LLVM_LINK_LLVM_DYLIB, it must be declared with LLVM_ALWAYS_EXPORT.

For importing:
The annotation LLVM_ABI is required in the body of the macro HANDLE_EXTENTION, which generates the declaration of getPollyPluginInfo from the CMake-generated file "llvm/Support/Extension.def".


Full diff: https://github.com/llvm/llvm-project/pull/156440.diff

8 Files Affected:

  • (modified) clang/lib/CodeGen/BackendUtil.cpp (+1-1)
  • (modified) flang/lib/Frontend/FrontendActions.cpp (+1-1)
  • (modified) llvm/docs/WritingAnLLVMNewPMPass.rst (+2-2)
  • (modified) llvm/lib/Extensions/Extensions.cpp (+1-1)
  • (modified) llvm/lib/LTO/LTOBackend.cpp (+1-1)
  • (modified) llvm/tools/bugpoint/bugpoint.cpp (+1-1)
  • (modified) llvm/tools/opt/NewPMDriver.cpp (+1-1)
  • (modified) polly/include/polly/RegisterPasses.h (+3-1)
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 3f095c03397fd..2e6f9e90f2db6 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -94,7 +94,7 @@ using namespace clang;
 using namespace llvm;
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 namespace llvm {
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 3bef6b1c31825..e61dee5e26636 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -87,7 +87,7 @@ constexpr llvm::StringLiteral timingIdBackend =
 
 // Declare plugin extension function declarations.
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 /// Save the given \c mlirModule to a temporary .mlir file, in a location
diff --git a/llvm/docs/WritingAnLLVMNewPMPass.rst b/llvm/docs/WritingAnLLVMNewPMPass.rst
index ea30d637347f1..5e41a939081a3 100644
--- a/llvm/docs/WritingAnLLVMNewPMPass.rst
+++ b/llvm/docs/WritingAnLLVMNewPMPass.rst
@@ -254,7 +254,7 @@ See the definition of ``add_llvm_pass_plugin`` for more CMake details.
 The pass must provide at least one of two entry points for the new pass manager,
 one for static registration and one for dynamically loaded plugins:
 
-- ``llvm::PassPluginLibraryInfo get##Name##PluginInfo();``
+- ``LLVM_ABI llvm::PassPluginLibraryInfo get##Name##PluginInfo();``
 - ``extern "C" ::llvm::PassPluginLibraryInfo llvmGetPassPluginInfo() LLVM_ATTRIBUTE_WEAK;``
 
 Pass plugins are compiled and linked dynamically by default. Setting
@@ -268,7 +268,7 @@ To make ``PassBuilder`` aware of statically linked pass plugins:
 .. code-block:: c++
 
     // Declare plugin extension function declarations.
-    #define HANDLE_EXTENSION(Ext) llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+    #define HANDLE_EXTENSION(Ext) LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
     #include "llvm/Support/Extension.def"
 
     ...
diff --git a/llvm/lib/Extensions/Extensions.cpp b/llvm/lib/Extensions/Extensions.cpp
index 0d25cbda38e00..67b1fa087e0c1 100644
--- a/llvm/lib/Extensions/Extensions.cpp
+++ b/llvm/lib/Extensions/Extensions.cpp
@@ -1,6 +1,6 @@
 #include "llvm/Passes/PassPlugin.h"
 #define HANDLE_EXTENSION(Ext)                                                  \
-		llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index ce42fc526beac..37ff7a4968e41 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -178,7 +178,7 @@ Error Config::addSaveTemps(std::string OutputFileName, bool UseInputModulePath,
 }
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 #undef HANDLE_EXTENSION
 
diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp
index 87581e80a2496..741374bfaf162 100644
--- a/llvm/tools/bugpoint/bugpoint.cpp
+++ b/llvm/tools/bugpoint/bugpoint.cpp
@@ -93,7 +93,7 @@ class AddToDriver : public legacy::FunctionPassManager {
 }
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 int main(int argc, char **argv) {
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index b9b8929a0f703..81909ea94f227 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -344,7 +344,7 @@ static void registerEPCallbacks(PassBuilder &PB) {
 }
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 #undef HANDLE_EXTENSION
 
diff --git a/polly/include/polly/RegisterPasses.h b/polly/include/polly/RegisterPasses.h
index 3a81e1ba7487d..3c358c8d77d4c 100644
--- a/polly/include/polly/RegisterPasses.h
+++ b/polly/include/polly/RegisterPasses.h
@@ -13,6 +13,8 @@
 #ifndef POLLY_REGISTER_PASSES_H
 #define POLLY_REGISTER_PASSES_H
 
+#include "llvm/Support/Compiler.h"
+
 namespace llvm {
 class PassRegistry;
 class PassBuilder;
@@ -27,6 +29,6 @@ void initializePollyPasses(llvm::PassRegistry &Registry);
 void registerPollyPasses(llvm::PassBuilder &PB);
 } // namespace polly
 
-llvm::PassPluginLibraryInfo getPollyPluginInfo();
+LLVM_ALWAYS_EXPORT llvm::PassPluginLibraryInfo getPollyPluginInfo();
 
 #endif

@llvmbot
Copy link
Member

llvmbot commented Sep 7, 2025

@llvm/pr-subscribers-clang-codegen

Author: Tomohiro Kashiwada (kikairoya)

Changes

Fixes #152328

For exporting:
Since the declaration/definition of getPollyPluginInfo is embedded into the LLVM DLL using add_llvm_pass_plugin, which defines LLVM_BUILD_STATIC by the effect of DISABLE_LLVM_LINK_LLVM_DYLIB, it must be declared with LLVM_ALWAYS_EXPORT.

For importing:
The annotation LLVM_ABI is required in the body of the macro HANDLE_EXTENTION, which generates the declaration of getPollyPluginInfo from the CMake-generated file "llvm/Support/Extension.def".


Full diff: https://github.com/llvm/llvm-project/pull/156440.diff

8 Files Affected:

  • (modified) clang/lib/CodeGen/BackendUtil.cpp (+1-1)
  • (modified) flang/lib/Frontend/FrontendActions.cpp (+1-1)
  • (modified) llvm/docs/WritingAnLLVMNewPMPass.rst (+2-2)
  • (modified) llvm/lib/Extensions/Extensions.cpp (+1-1)
  • (modified) llvm/lib/LTO/LTOBackend.cpp (+1-1)
  • (modified) llvm/tools/bugpoint/bugpoint.cpp (+1-1)
  • (modified) llvm/tools/opt/NewPMDriver.cpp (+1-1)
  • (modified) polly/include/polly/RegisterPasses.h (+3-1)
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 3f095c03397fd..2e6f9e90f2db6 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -94,7 +94,7 @@ using namespace clang;
 using namespace llvm;
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 namespace llvm {
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 3bef6b1c31825..e61dee5e26636 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -87,7 +87,7 @@ constexpr llvm::StringLiteral timingIdBackend =
 
 // Declare plugin extension function declarations.
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 /// Save the given \c mlirModule to a temporary .mlir file, in a location
diff --git a/llvm/docs/WritingAnLLVMNewPMPass.rst b/llvm/docs/WritingAnLLVMNewPMPass.rst
index ea30d637347f1..5e41a939081a3 100644
--- a/llvm/docs/WritingAnLLVMNewPMPass.rst
+++ b/llvm/docs/WritingAnLLVMNewPMPass.rst
@@ -254,7 +254,7 @@ See the definition of ``add_llvm_pass_plugin`` for more CMake details.
 The pass must provide at least one of two entry points for the new pass manager,
 one for static registration and one for dynamically loaded plugins:
 
-- ``llvm::PassPluginLibraryInfo get##Name##PluginInfo();``
+- ``LLVM_ABI llvm::PassPluginLibraryInfo get##Name##PluginInfo();``
 - ``extern "C" ::llvm::PassPluginLibraryInfo llvmGetPassPluginInfo() LLVM_ATTRIBUTE_WEAK;``
 
 Pass plugins are compiled and linked dynamically by default. Setting
@@ -268,7 +268,7 @@ To make ``PassBuilder`` aware of statically linked pass plugins:
 .. code-block:: c++
 
     // Declare plugin extension function declarations.
-    #define HANDLE_EXTENSION(Ext) llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+    #define HANDLE_EXTENSION(Ext) LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
     #include "llvm/Support/Extension.def"
 
     ...
diff --git a/llvm/lib/Extensions/Extensions.cpp b/llvm/lib/Extensions/Extensions.cpp
index 0d25cbda38e00..67b1fa087e0c1 100644
--- a/llvm/lib/Extensions/Extensions.cpp
+++ b/llvm/lib/Extensions/Extensions.cpp
@@ -1,6 +1,6 @@
 #include "llvm/Passes/PassPlugin.h"
 #define HANDLE_EXTENSION(Ext)                                                  \
-		llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index ce42fc526beac..37ff7a4968e41 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -178,7 +178,7 @@ Error Config::addSaveTemps(std::string OutputFileName, bool UseInputModulePath,
 }
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 #undef HANDLE_EXTENSION
 
diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp
index 87581e80a2496..741374bfaf162 100644
--- a/llvm/tools/bugpoint/bugpoint.cpp
+++ b/llvm/tools/bugpoint/bugpoint.cpp
@@ -93,7 +93,7 @@ class AddToDriver : public legacy::FunctionPassManager {
 }
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
 int main(int argc, char **argv) {
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index b9b8929a0f703..81909ea94f227 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -344,7 +344,7 @@ static void registerEPCallbacks(PassBuilder &PB) {
 }
 
 #define HANDLE_EXTENSION(Ext)                                                  \
-  llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
+  LLVM_ABI llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 #undef HANDLE_EXTENSION
 
diff --git a/polly/include/polly/RegisterPasses.h b/polly/include/polly/RegisterPasses.h
index 3a81e1ba7487d..3c358c8d77d4c 100644
--- a/polly/include/polly/RegisterPasses.h
+++ b/polly/include/polly/RegisterPasses.h
@@ -13,6 +13,8 @@
 #ifndef POLLY_REGISTER_PASSES_H
 #define POLLY_REGISTER_PASSES_H
 
+#include "llvm/Support/Compiler.h"
+
 namespace llvm {
 class PassRegistry;
 class PassBuilder;
@@ -27,6 +29,6 @@ void initializePollyPasses(llvm::PassRegistry &Registry);
 void registerPollyPasses(llvm::PassBuilder &PB);
 } // namespace polly
 
-llvm::PassPluginLibraryInfo getPollyPluginInfo();
+LLVM_ALWAYS_EXPORT llvm::PassPluginLibraryInfo getPollyPluginInfo();
 
 #endif

@efriedma-quic
Copy link
Collaborator

The export side of this looks like a CMake bug: if we're linking code into the LLVM dylib, add_llvm_pass_plugin() should configure LLVM_ABI so it exports any marked functions.

Import side looks fine.

@kikairoya
Copy link
Contributor Author

The export side of this looks like a CMake bug: if we're linking code into the LLVM dylib, add_llvm_pass_plugin() should configure LLVM_ABI so it exports any marked functions.

Having reconsidered this, DISABLE_LLVM_LINK_LLVM_DYLIB seems to behave more like -Wl,-Bstatic, i.e. "this is built on top of libLLVM; link it statically," rather than "this is part of libLLVM."
I think we need a new option for add_llvm_library to handle this case explicitly, named something like MERGE_INTO_LLVM_DYLIB.

I've posted a new PR: #158023

Copy link
Collaborator

@efriedma-quic efriedma-quic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category flang:driver flang Flang issues not falling into any other category LTO Link time optimization (regular/full LTO or ThinLTO)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

link errors when building LLVM as a Windows DLL with polly project included

3 participants